<?php
$objMlogs 		= new Mlogs();
$objVfriendUser	= new Vfriend_User();

$arrData		= $objMlogs->getMlog();
if($arrData) {
	foreach($arrData as $value) {		
		$intType		= $value['type'];
		$objUser		= $objVfriendUser->getInfo($value['userid']);
		$objPoster		= $objVfriendUser->getInfo($value['content']['posterid']);
		if($intType == 1) {
		}elseif($intType == 30) {
			$strSubject		= API_EMAIL_BLOG;
		}elseif($intType == 31) {
			$strSubject		= API_EMAIL_BLOG_CMT;
		}elseif($intType == 40) {
			$strSubject		= API_EMAIL_PHOTO;
		}elseif($intType == 41) {
			$strSubject		= API_EMAIL_PHOTO_CMT;
		}elseif($intType == 50) {
			$strSubject		= API_EMAIL_BLAST;
		}elseif($intType == 51) {
			$strSubject		= API_EMAIL_BLAST_CMT;
		}elseif($intType == 60) {
			$strSubject		= API_EMAIL_BLAST;
		}elseif($intType == 61) {
			$strSubject		= API_EMAIL_BLAST_CMT;
		}elseif($intType == 62) {
			$strSubject		= API_EMAIL_OFFLINE_REG;
		}elseif($intType == 63) {
			$strSubject		= API_EMAIL_OFFLINE_INVITE;
		}elseif(abs($intType) == 64) {
			if($intType == 64)
				$strSubject	= API_EMAIL_OFFLINE_INV_AC;
			else
				$strSubject	= API_EMAIL_OFFLINE_INV_DE;
		}elseif(abs($intType) == 65) {
			if($intType == 65)
				$strSubject	= API_EMAIL_OFFLINE_ACCEPTED;
			else
				$strSubject	= API_EMAIL_OFFLINE_DENIED;
		}elseif($intType == 66) {
			$strSubject		= API_EMAIL_OFFLINE_INVITE;
		}elseif($intType == 67) {
			$strSubject		= API_EMAIL_OFFLINE_JOIN_CAN;
		}
		$strSubject				= str_replace('[strFullName]', $objPoster->fullnamevn, $strSubject);
		if($value['content']['title'] != '') {
			$strSubject			= str_replace('[strTitle]', Vfriend_Function::wordCut($value['content']['title'],33), $strSubject);
		}elseif($value['content']['cmt'] != '' && $intType == 50) {
			$strSubject			= str_replace('[strTitle]', Vfriend_Function::wordCut($value['content']['cmt'],33), $strSubject);
		}
		$this->view->objUser	= $objUser;
		$this->view->objPoster	= $objPoster;
		$this->view->row		= $value;
		$objView 				= Zend_Registry::get('objView'); 
		$strContent 			= $objView->fetch('email/notification.tpl');
		$objMail				= new Vfriend_Mail();
		$intSend 				= $objMail->send(EMAIL_NOREPLY, EMAIL_NOREPLY_NAME, $objUser->email, $strSubject, $strContent);
		if($intSend) {
			$objMlogs->deleteById($value['_id']);
		}
	}
}
exit();
?>
